package org.csu.mypetstorebackstage.service;

import org.csu.mypetstorebackstage.domain.Category;
import org.csu.mypetstorebackstage.domain.Product;
import org.csu.mypetstorebackstage.persistence.CategoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryService {
    @Autowired
    private CategoryMapper categoryMapper;

    public Category getCategoryByName(String name)
    {
        return categoryMapper.getCategoryByName(name);
    }

    public List<Category> getCategoryAll()
    {
        return categoryMapper.getCategoryAll();
    }

    public List<Product> showOnSellProduct() {
        return categoryMapper.getOnsell();
    }

    public List<Product> showOutShelfProduct(){
        return categoryMapper.getOutshelf();
    }
    public int getItemNumberByProductId(String productId){
        return categoryMapper.getItemByProductId(productId).size();
    }

    public void updateOnShelf(String productId){
        categoryMapper.updateOnShelf(productId);
    }

    public void updateOutShelf(String productId){
        categoryMapper.updateOutShelf(productId);
    }

}
